home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
comm
/
tcp
/
Amster-main.lha
/
Amster_Install
/
Rexx
/
AmsterControl.amirx
< prev
next >
Wrap
Text File
|
2000-09-16
|
6KB
|
168 lines
/*
** Amster Control Script For AmIRC
** $VER: AmsterControl.amirc 0.1 (15.9.2000)
**
** By Roger Clark (kaedric@texas.net)
** September 15, 2000
**
** Run this script from AmIRC's pulldown menu. You can then send commands to
** the scripts Arexx port 'AMSTERCONTROL'. The easiest way to do this is to
** set up an Alias in AmIRC: /RX "Address 'AMSTERCONTROL' %p"
**
** Commands: CONNECT, DISCONNECT, STATS, WHOIS {user}, SEARCH {string}, DOWNLOAD {file number}, QUIT
**
*/
Options Results
Link.0 = "Unknown"
Link.1 = "14.4K Modem"
Link.2 = "28.8K Modem"
Link.3 = "33.6K Modem"
Link.4 = "56K Modem"
Link.5 = "ISDN 64K"
Link.6 = "ISDN 128K"
Link.7 = "Cable"
Link.8 = "DSL"
Link.9 = "T1"
Link.10 = "T3+"
If ~show('l','rexxsupport.library') then Do
If ~addlib('rexxsupport.library',0,-30,0) then Do
say "Couldn't access rexxsupport.library!"
Exit 5
End
End
If ~show('l','rexxarplib.library') then Do
If ~addlib('rexxarplib.library',0,-30,0) then Do
say "Couldn't access rexxarplib.library!"
Exit 5
End
End
CreatePort:
MyPort = OpenPort("AMSTERCONTROL")
If MyPort = 0 Then Do
'Echo P='d2c(27)'b«Amster» Unable to create Arexx Port'
Exit
End
Else Do
'Echo P='d2c(27)'b«Amster» Amster Control is now active.'
End
WaitOnPort:
Call WaitPkt("AMSTERCONTROL")
Packet = GetPkt("AMSTERCONTROL")
If Packet = "00000000"x Then Signal WaitOnPort
Command = GetArg(Packet)
StartHere:
If Show('P','AMSTER.1') Then Do
Select
When Upper(Command) = "STATS" Then Do
Address 'AMSTER.1' 'GETSERVERSTATS INFO'
If RC = 0 Then Do
Day = Date('N',INFO.CONNECTTIME % (60*60*24), 'I')
ElapSec = ((INFO.CONNECTTIME / (60*60*24)) - (INFO.CONNECTTIME % (60*60*24))) * 60 * 60 * 24 % 1
Hours = ElapSec % 3600
Minutes = (ElapSec % 60) - (Hours * 60)
Seconds = ElapSec - (Hours * 3600) - (Minutes * 60) + 1
OnlineTime = Hours":"Right("00"||Minutes,2)":"Right("00"||Seconds,2)
'Echo P='d2c(27)'b«Amster» 'INFO.SERVER':'INFO.PORT' (connected since 'OnlineTime')'
'Echo P='d2c(27)'b«Amster» 'INFO.SONGS' songs in 'INFO.USERS' libraries ('INFO.GIGABYTES' GB)'
End
Else If RC = 5 Then Do
'Echo P='d2c(27)'b«Amster» Not currently connected to a server.'
End
End
When Upper(Word(Command,1)) = "SEARCH" Then Do
'Echo P='d2c(27)'b«Amster» Searching for "'SubWord(Command,2)'"'
Address 'AMSTER.1' 'SEARCH "'SubWord(Command,2)'" SONG'
If SONG.COUNT > 0 Then Do
'Echo P='d2c(27)'b«Amster» Found 'SONG.COUNT' matches.'
Do Loop = 0 to SONG.COUNT - 1
Speed = SONG.Loop.LINK
Name = SubStr(SONG.Loop.TITLE,LastPos('\',SONG.Loop.TITLE) +1)
Minutes = (SONG.Loop.TIME % 60)
Seconds = SONG.Loop.TIME - (Minutes * 60)
PlayTime = Minutes":"Right("00"||Seconds,2)
'Echo P='d2c(27)'b«Amster» 'Loop': 'Name' ['Playtime'/'Link.Speed'/'SONG.Loop.BITRATE'kbps]'
End
End
Else Do
'Echo P='d2c(27)'b«Amster» No matches found.'
End
End
When Upper(Word(Command,1)) = "CONNECT" Then Do
'Echo P='d2c(27)'b«Amster» Connecting to new server'
Address 'AMSTER.1' 'CONNECT'
Call CheckOnline
Command = "STATS"
Signal StartHere
End
When Upper(Word(Command,1)) = "DISCONNECT" Then Do
'Echo P='d2c(27)'b«Amster» Disconnecting from server'
Address 'AMSTER.1' 'DISCONNECT'
End
When Upper(Word(Command,1)) = "WHOIS" Then Do
Address 'AMSTER.1' 'WHOIS 'Word(Command,2)' LUSER'
If RC = 0 Then Do
Speed = LUSER.LINK
Hours = LUSER.TIME % 3600
Minutes = (LUSER.TIME % 60) - (Hours * 60)
Seconds = LUSER.TIME - (Hours * 3600) - (Minutes * 60)
OnlineTime = Hours":"Right("00"||Minutes,2)":"Right("00"||Seconds,2)
'Echo P='d2c(27)'b«Amster» User: 'Luser.Nick' (level: 'Luser.Level') - online: 'OnlineTime' ('Luser.Status')'
If Luser.Channels ~= "" then 'Echo P='d2c(27)'b«Amster» Channels: 'Luser.Channels
'Echo P='d2c(27)'b«Amster» Shares: 'Luser.Shares', downloads: 'Luser.Downloads', uploads: 'Luser.Uploads
'Echo P='d2c(27)'b«Amster» Client: 'Luser.Client', link: 'Link.Speed
End
Else If RC = 1 Then Do
Logoff = Date('N',LUSER.LASTSEEN % (60*60*24), 'I')
ElapSec = ((LUSER.LASTSEEN / (60*60*24)) - (LUSER.LASTSEEN % (60*60*24))) * 60 * 60 * 24 % 1
Hours = ElapSec % 3600
Minutes = (ElapSec % 60) - (Hours * 60)
Seconds = ElapSec - (Hours * 3600) - (Minutes * 60)
OfflineTime = Hours":"Right("00"||Minutes,2)":"Right("00"||Seconds,2)
'Echo P='d2c(27)'b«Amster» User: 'Luser.Nick' (level: 'Luser.Level') - last seen 'Logoff' 'OfflineTime
End
Else Do
'Echo P='d2c(27)'b«Amster» 'd2c(2)'Error: 'd2c(2)||Word(Command,2)' is not a known user'
End
End
When Upper(Word(Command,1)) = "DOWNLOAD" Then Do
Choice = Word(Command,2)
If Choice < 0 | Choice > SONG.COUNT Then Do
'Echo P='d2c(27)'b«Amster» Invalid selection.'
End
Else Do
Name = SubStr(SONG.Choice.TITLE,LastPos('\',SONG.Choice.TITLE) +1)
'Echo P='d2c(27)'b«Amster» Downloading 'Name
Address 'AMSTER.1' 'DOWNLOAD 'Choice
End
End
When Upper(Command) = "QUIT" Then Do
'Echo P='d2c(27)'b«Amster» Control script is exiting.'
Reply(Packet,0)
Call ClosePort("AMSTERCONTROL")
Exit
End
Otherwise 'Echo P='d2c(27)'b«Amster» Available commands: CONNECT, DISCONNECT, STATS, WHOIS {user}, SEARCH {string}, DOWNLOAD {file number}, QUIT'
End
End
Reply(Packet,0)
Signal WaitOnPort
CheckOnline:
If Show('P','AMSTER.1') = 0 then Do
'Echo P='d2c(27)'b«Amster» Could not locate Amster''s Arexx port.'
End
Address 'AMSTER.1' 'ISONLINE'
If RC = 0 then Do
Do While RC = 0
Call Delay(50)
Address 'AMSTER.1' 'ISONLINE'
End
End
Return